package listbyorder.access201_300.test238;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/6/27 10:06
 */
public class Solution1 {

    public int[] productExceptSelf(int[] nums) {
        int len = nums.length;
        int[] left = new int[len];
        int[] right = new int[len];
        left[0] = 1;
        right[len - 1] = 1;
        for (int i = 1; i < len; i++) {
            left[i] = left[i - 1] * nums[i - 1];
            right[len - 1 - i] = right[len - i] * nums[len - i];
        }
        for (int i = 0; i < len; i++) {
            left[i] = left[i] * right[i];
        }
        return left;
    }
}
